- convert the above two functions to iterative processes
- implement peano addition
- implement peano multiplication (an iterative process will suit this one)
- implement peano subtraction
- implement peano division
- implement peano exponentiation
- implement square root (might use same algo as division; in sicp there is an example)
- implement peano modulo pn

#+BEGIN_SRC scheme
(define-record-type :pare
  (kons x y)
  pare?
  (x kar set-kar!)
  (y kdr))
#+END_SRC

Syntax definitions

# Record types

#+BEGIN_SRC scheme
(define (record-type record)
  (record-ref record 0))
#+END_SRC

R5RS

(defclass (peano-successor predecessor))

#+BEGIN_SRC python
class peano_successor:
    def __init__(predecessor):
        self.predecessor = predecessor;
    def predecessor(self):
        return self.predecessor;

def is_peano_successor(val):
    return instance_of(val, 'peano_successor');
#+END_SRC




||||
\

||||
\
|||

III

IV

V
VI

IIIIIIIII
IX

#+BEGIN_SRC scheme
(define (make-traced f)
  (lambda args
    (display "calling (")
    (display f)
    (for-each (lambda (arg)
                (display " ")
                (display arg))
              args)
    (display ")\n")
    (let ((res (apply f args)))
      (display "= ")
      (display res)
      (newline)
      res)))

(define peano-predecessor* (make-traced peano-predecessor))

#+END_SRC

#+BEGIN_SRC scheme
(use-modules (ice-9 debugging trace))
(trace peano-predecessor)
#+END_SRC
